package aclInfoCollector.filesAnalysers.component.fractalFile;

import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;


/**La classe ErrorHandlerFractalParser permet de mieux discerner les erreurs au cours du parsage d'un document fractal
*@version 1.0
*@author Bendavid Olivier
*@author Haderer Nicolas
*/


public class ErrorHandlerFractalParser implements ErrorHandler{


	protected String message(SAXParseException e){
		String message = "Message : "+e.getMessage()+"\n";
		message += "Ligne "+e.getLineNumber()+", colonne "+e.getColumnNumber()+"\n";
		message += "Public id : "+e.getPublicId()+"\n";
		message += "System id : "+e.getSystemId();
		return message;
	}
	protected void printSAXException(SAXParseException e){
		System.out.println(message(e));
		if(e.getException() != null){
			e.getException().printStackTrace();
		}
	}
	public void warning(SAXParseException exception) throws SAXException{
		System.out.println("*** Warning ***");
		printSAXException(exception);
	}
	public void error(SAXParseException exception) throws SAXException{
		System.out.println("*** Erreur ***");
		printSAXException(exception);
	}
	public void fatalError(SAXParseException exception) throws SAXException{
		String message = "*** Erreur fatale ***\n";
		message += message(exception);
		SAXException se = new SAXException(message, exception);
		throw se;
	}
	}


